using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using NBear.Common;

public partial class AjaxTemplates_DataBinding : NBear.Web.UI.AjaxTemplate
{
    private SampleEntity[] objs = null;

    private void LoadSampleEntities(int num)
    {
        objs = new SampleEntity[num];

        for (int i = 0; i < num; i++)
        {
            objs[i] = EntityFactory<SampleEntity>.CreateObject();
            objs[i].ID = i + 1;
            objs[i].Name = Guid.NewGuid().ToString();
        }
    }

    public override void OnAjaxTemplatePreRender(System.Collections.Generic.Dictionary<string, string> callbackParams)
    {
        LoadSampleEntities(int.Parse(callbackParams["num"]));

        GridView1.DataSource = objs;
        GridView1.DataBind();
    }
}
